export default function (url) {
  uni.showLoading({
    title: '正在保存'
  })
  uni.getImageInfo({
    src: url,
    success: (res) => {
      uni.saveImageToPhotosAlbum({
        filePath: res.path,
        success: () => {
          uni.showToast({
            title: '保存成功'
          })
        },
        fail: (err) => {
          if (err.errMsg === 'saveImageToPhotosAlbum:fail auth deny') {
            uni.showModal({
              content: '您需要授权才能保存图片',
              confirmText: '去授权',
              confirmColor: '#409EFF',
              success: (modalRes) => {
                if (modalRes.confirm) {
                  uni.openSetting()
                }
              }
            })
          }
        },
        complete: () => uni.hideLoading()
      })
    }
  })
}